#include "qipadresseditor.h"

#include "../shared/qipaddressspinbox.h"
#include "../property/qabstractproperty.h"

#include <QPainter>
#include <QKeyEvent>

QIpAddressEditor::QIpAddressEditor(QAbstractProperty *property,QWidget *parent) :
    QAbstractPropertyEditor(property,parent),
    m_address_spinbox(new QIpAddressSpinBox(this))
{
    m_address_spinbox->setAddress(m_property->get_value().toInt());
    connect(m_address_spinbox,SIGNAL(address_changed(int)),this,SLOT(value_changed(int)));
}

void QIpAddressEditor::value_changed(int address)
{
    if(address!=m_property->get_value().toInt())
    {
        emit property_changed(address);
    }
}

void QIpAddressEditor::property_value_changed()
{
    m_address_spinbox->setAddress(m_property->get_value().toInt());
}

qRegisterPropertyEditor("IPAdress",QIpAddressEditor)
